﻿//--------------------------------------------------------------------------------------------------------------------------------------------------------
// <copyright file="SecurityAction.cs">
//     Copyright © 2010 Oli Francis
//     This source code is subject to the terms and conditions of the MIT license. A copy of the license can be found in the license.txt 
//     file at the root of this distribution. By using this source code in any fashion, you are agreeing to be bound by the terms of the MIT License. 
//     You must not remove this notice from the software.
// </copyright>
// <author>Oli</author>
//-------------------------------------------------------------------------------------------------------------------------------------------------------

namespace TeamBrain.Tests.Units.Security
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using Moq;

    using NUnit.Framework;

    using TeamBrain.Domain.Core;
    using TeamBrain.Domain.Core.Repositories;
    using TeamBrain.Domain.Services.Configuration;
    using TeamBrain.Domain.Services.Email;
    using TeamBrain.Domain.Services.Security;

    public abstract class SecurityAction
    {
        protected ISecurityService SecurityService { get; set; }

        protected Mock<IUnitOfWork> UnitOfWork { get; set; }

        protected Mock<IAuthenticationProvider> AuthenticationProvider { get; set; }

        protected Mock<IUserRepository> UserRepository { get; set; }

        protected Mock<IPasswordHasher> PasswordHasher { get; set; }

        protected Mock<IConfiguration> Configuration { get; set; }

        protected Mock<IEmailService> EmailService { get; set; }

        [SetUp]
        public void Initialize()
        {
            this.UnitOfWork = new Mock<IUnitOfWork>();
            this.AuthenticationProvider = new Mock<IAuthenticationProvider>();
            this.UserRepository = new Mock<IUserRepository>();
            this.PasswordHasher = new Mock<IPasswordHasher>();
            this.EmailService = new Mock<IEmailService>();
            this.Configuration = new Mock<IConfiguration>();
            this.Configuration.SetupGet(c => c.MinutesUntilLockoutExpires).Returns(10);
            this.Configuration.SetupGet(c => c.SignInAttemptsBeforeLockout).Returns(4);
            this.Configuration.SetupGet(c => c.PasswordResetValidForHours).Returns(24);

            this.SecurityService = new SecurityService(
                this.UnitOfWork.Object,
                this.AuthenticationProvider.Object,
                this.UserRepository.Object,
                this.PasswordHasher.Object,
                this.Configuration.Object,
                this.EmailService.Object);
        }
    }
}
